use sqlx::{Error, Pool, Postgres};
use uuid::Uuid;
use void_log::log_info;
use crate::model::satori::SatoriGuild;

impl SatoriGuild {
    pub async fn select(pool: &Pool<Postgres>, id: &Uuid) -> Result<SatoriGuild, Error> {
        log_info!("[ Satori ] 按 Id: {id} 查询群组");
        let sql = "SELECT * FROM sys_guild where id = $1";
        sqlx::query_as::<_, Self>(sql).bind(id).fetch_one(pool).await
    }

    pub fn new(id: &str) -> Self {
        Self {
            id: id.to_string(),
            name: None,
            avatar: None,
        }
    }
}